package cn.rubintry.bug.hunting.common.http.viewmodel

import androidx.activity.ComponentActivity
import androidx.lifecycle.MutableLiveData
import cn.rubintry.bug.lib.network.http.viewmodel.BaseViewModel
import cn.rubintry.bug.hunting.common.http.api.WebApi
import cn.rubintry.bug.hunting.pojo.ArticleModel
import cn.rubintry.bug.hunting.pojo.BaseModel
import cn.rubintry.bug.lib.network.http.NetApiManager

class HomeViewModel() : BaseViewModel() {

    val articleData =MutableLiveData<BaseModel<List<ArticleModel>>>()

    fun getArticleWithLimit(start: Int, limit: Int, fromRefreshing: Boolean , loadMore: Boolean = false){
        request<WebApi, BaseModel<List<ArticleModel>>>(
            NetApiManager.getInstance().getApi(WebApi::class.java),
            WebApi::getArticleWithLimit,
            !fromRefreshing,
            { data ->
                data?.let {
                    it.loadMore = loadMore
                    articleData.value = it
                }
            },start.toString() , limit.toString())
    }
}